package com.yc.bdw.Activity;

import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.yc.bdw.R;
import com.yc.bdw.Utils.Constant;

import org.kymjs.kjframe.KJActivity;
import org.kymjs.kjframe.KJHttp;
import org.kymjs.kjframe.http.HttpCallBack;
import org.kymjs.kjframe.ui.BindView;

public class LoginActivity extends KJActivity {

    private String getstr;
    private String username;
    private String password;


    @BindView(id = R.id.iv_login, click = true)
    private ImageView iv_login;
    @BindView(id=R.id.et_username)
    private EditText et_username;
    @BindView(id=R.id.et_password)
    private EditText et_password;

    @Override
    public void setRootView() {
        setContentView(R.layout.activity_login);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void widgetClick(View v) {
        super.widgetClick(v);
        switch (v.getId()) {
            case R.id.iv_login:
                username = et_username.getText().toString().trim();
                password = et_password.getText().toString().trim();
                getstr = Constant.BDW_LOGIN+"loginName="+username+"&password="+password;
                Log.d("Login",getstr);
                new Login().execute(getstr);
                break;

        }
    }
    class Login extends AsyncTask<String, Void,Void> {
        String url;
        @Override
        protected Void doInBackground(String... params) {

            KJHttp kjh = new KJHttp();
            url = params[0];
            Log.d("Login",url);
            kjh.get(url, new HttpCallBack(){


                @Override
                public void onPreStart() {
                    super.onPreStart();
                }

                @Override
                public void onSuccess(String t) {
                    super.onSuccess(t);

                }

                @Override
                public void onFailure(int errorNo, String strMsg) {
                    super.onFailure(errorNo, strMsg);
                }

                @Override
                public void onFinish() {
                    super.onFinish();
                }
            });




            return null;
        }
    }
    }
